using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;

namespace WebApiFrame.Filters
{

    public class MyActionFilterAttribute : TypeFilterAttribute
    {
        public MyActionFilterAttribute() : base(typeof(MyActionFilterImpl))
        {
        }
        
    public class MyActionFilterImpl :Attribute, IActionFilter
    {

        private readonly string _key;
        private readonly string _value;


        private readonly ILogger<MyActionFilterImpl>logger;
        //    public MyActionFilterImpl (string key,string value,ILoggerFactory loggerFactory)
        // {
        //     _key=key;
        //     _value=value;
        //       logger=loggerFactory.CreateLogger<MyActionFilterImpl>();
        // }
        public MyActionFilterImpl (ILoggerFactory loggerFactory)
        {
              logger=loggerFactory.CreateLogger<MyActionFilterImpl>();
        }
        public void OnActionExecuted(ActionExecutedContext context)
        {
           // throw new NotImplementedException();
        }

        public void OnActionExecuting(ActionExecutingContext context)
        {
          context.HttpContext.Response.Headers.Add("123","456");
        }
    }

    }
}